package minTimeToVisitAllPoints;

public class Solution {
    public int minTimeToVisitAllPoints(int[][] points) {
        //切比雪夫距离
        int t=0;
        for (int i = 0; i < points.length-1; i++) {
            int currentX=points[i][0];
            int currentY=points[i][1];
            int nextX=points[i+1][0];
            int nextY=points[i+1][1];
            int disX=Math.abs(nextX-currentX);
            int disY=Math.abs(nextY-currentY);
            if(disX==0){
                t+=disY;
            }else if(disY==0){
                t+=disX;
            }else{
                t+=Math.max(disX,disY);
            }
        }
        return t;
    }
}
